fix: improve SSE event handling to gracefully ignore unrecognized events#423
Closed
tzolov wants to merge 5 commits intomodelcontextprotocol:mainfrom
Closed
fix: improve SSE event handling to gracefully ignore unrecognized events#423tzolov wants to merge 5 commits intomodelcontextprotocol:mainfrom
tzolov wants to merge 5 commits intomodelcontextprotocol:mainfrom
Conversation
- Replace McpError exceptions with debug/warning logs for unrecognized SSE event types - Continue processing instead of failing when encountering unknown SSE events - Update transport implementations: - WebClientStreamableHttpTransport: return empty tuple instead of throwing - WebFluxSseClientTransport: complete stream instead of erroring - HttpClientSseClientTransport: call sink.success() instead of sink.error() - HttpClientStreamableHttpTransport: return empty Flux for unknown events This improves client resilience when servers send non-standard or future SSE event types. Resolves modelcontextprotocol#272 , modelcontextprotocol#223 , modelcontextprotocol#93 Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
9 tasks
sunyuhan1998
approved these changes
Jul 25, 2025
Contributor
sunyuhan1998
left a comment
There was a problem hiding this comment.
That's great! I think this PR can solve many issues.
chemicL
approved these changes
Jul 25, 2025
tzolov
added a commit
that referenced
this pull request
Jul 25, 2025
…nts (#423) - Replace McpError exceptions with debug/warning logs for unrecognized SSE event types - Continue processing instead of failing when encountering unknown SSE events - Update transport implementations: - WebClientStreamableHttpTransport: return empty tuple instead of throwing - WebFluxSseClientTransport: complete stream instead of erroring - HttpClientSseClientTransport: call sink.success() instead of sink.error() - HttpClientStreamableHttpTransport: return empty Flux for unknown events This improves client resilience when servers send non-standard or future SSE event types. Resolves #272 , #223 , #93, #421 Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Contributor
Author
|
Rebased, squashed and merged at c3a0b18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change improves client resilience by gracefully handling unknown events instead of failing, allowing clients to continue processing valid events even when encountering unexpected ones.
This improves client resilience when servers send non-standard or future SSE event types.
Resolves #272 , #223 , #93, #421
Improve SSE event handling to gracefully ignore unrecognized events instead of throwing errors
Motivation and Context
Previously, when MCP clients received unrecognized Server-Sent Events (SSE) from servers, they would throw
McpErrorexceptions and terminate the connection. This created fragility when::) are sent, which should be ignored per the SSE specificationHow Has This Been Tested?
testCommentSseMessage()to verify SSE comment lines are properly ignored:prefixed lines)Breaking Changes
No breaking changes. This is a backward-compatible improvement that makes clients more resilient. Existing functionality remains unchanged.
Types of changes
Checklist
Additional context
Implementation Details:
sink.success()with debug log instead ofsink.error()